package com.mojo.concurrent.container;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * hashmap并发死锁
 *
 * @author <a href="mailto:sjj@jianzhimao.com">mojo</a>
 * copyright (C), 2013-2023, 广州九尾信息科技有限公司
 * @date 2023/2/8 10:19
 */
public class HashMapDeadLock {


    public static void main(String[] args) throws InterruptedException {
        final Map<String, Object> map = new HashMap<>(2);
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    new Thread("ftf" + i) {
                        @Override
                        public void run() {
                            map.put(UUID.randomUUID().toString(), "");
                        }
                    }.start();
                }
            }
        }, "ftf");
        t1.start();
        t1.join();

    }
}
